//
//  BaseController+Messages.m
//  RomensBI
//
//  Created by 王增战 on 2017/1/23.
//
//

#import "BaseController+Messages.h"
#import <Hyphenate/EMSDK.h>
@implementation BaseController (Messages)


- (void)HX_addSyncNotification {
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(HX_GetUnreadMsgNumbers) name:UnReadMsgsNotificationName object:nil];
}

- (NSInteger)HX_GetUnreadMsgNumbers {
    //加载
    NSArray *conversations = [[EMClient sharedClient].chatManager getAllConversations];
    NSInteger unreadCount = 0;
    for (EMConversation *conversation in conversations) {
        unreadCount += conversation.unreadMessagesCount;
    }
    return unreadCount;
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self name:UnReadMsgsNotificationName object:nil];
}
@end
